import React, {Component} from 'react';
import store from "../Redux/index";
import {Action, changeInputAction} from "../Redux/action/actionCreator";
import sha1 from 'sha1';
// import AES from 'aes'
import  {aes} from "crypto-js/aes";
class Index extends Component {
    constructor(props) {
        super(props);
        this.state = {
            input1:store.getState(),
            input2:store.getState()
        }
        store.subscribe(this.storeChange.bind(this))
    }

    render() {
        console.log(store.getState())
        return (
            <div>
                账户：<input  onChange={this.change.bind(this)} type={"text"}/>
                密码<input  onChange={this.change1.bind(this)} type={"password"}/>

            </div>
        );
    }

    storeChange() {

    }

    change(e) {

        let name=sha1(e.target.value);
        let sha1_name=sha1(name);
        const action = changeInputAction(sha1_name);
        console.log(action)

        store.dispatch(action)
        this.setState({input1:store.getState()})
    }

    change1(e) {
        let password=sha1(e.target.value);
        let sha1_password=sha1(password);
        const action = Action(sha1_password);
        console.log(action)
        store.dispatch(action)
        this.setState({input2:store.getState()})
    }
}

export default Index;
